This class makes it easy to create an RSS Feed. I followed The Official RSS 2.0 Specifications at Harvard Law to a tee when creating this class, and the following websites were also helpful:
- The RSS Advisory Board
- Wikipedia's two bits
You don't have to worry about formatting any of your dates as we do all of that in-house. Any date that can be translated by PHP's strtotime() function will do just fine. After you're done, Validate Your RSS Feed to make sure you got things right. Finally, place the following at the top of every page that corresponds to your RSS Feed so that browsers will recognize it:
$page->link('<link rel="alternate" type="application/rss+xml" href="http://www.your-website.com/rss.xml" title="Your title" />');This is the constructor for the class, and it takes in the three required channel elements to get your RSS feed on it's feet.
| $title | The name of your RSS feed. |
| $link | The website link that corresponds to the feed. |
| $description | A short description of your feed. |
| Returns | An RSS object. |
| Example | |
This method allows you to insert all of the other optional channel elements into your feed. See the examples below. You don't have to keep calling this method for every element, you can just throw everything into an array and call the method only once.
| $elements | Key and value pairs of channel elements, and their values. |
| Example | |
According to the RSS Advisory Boards recommended best practices, this atom:link should be included in your feed, and it should point to the RSS Feed URL itself.
| Example | |
The language the channel is written in. See the Allowable values for language in RSS.
| Example | |
A copyright notice for the channel.
| Example | |
The email address of who is responsible for the content.
| Example | |
The email address of who is responsible for any techincal issues relating to the feed.
| Example | |
The channel's publication date.
| Example | |
The last time the content in the feed changed.
| Example | |
A general category that the feed would fall under.
| Example | |
Any software kudos you would like to give.
| Example | |
A URL that points to the documentation for the format used in the RSS file.
| Example | |
To specify a web service that supports the rssCloud interface. See SOAP meets RSS.
| Example | |
"Time To Live" - How long (in seconds) a channel should be cached before the source is refreshed.
| Example | |
A jpg, gif, or png image to display with the channel. The 'url', 'title', and 'link' values are required, the rest are optional. 'title' and 'link' should have the same values as the channel's title and link.
| Example | |
The PICS (an outdated protocol to describe web content) rating for the channel.
| Example | |
A text input box. Most aggregators ignore it. The purpose for this element is unclear.
| Example | |
An array of hours (between 0 and 23) when you don't want aggregators to read your channel.
| Example | |
An array of days ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') when you don't want aggregators to read your channel.
| Example | |
This method creates an item in your feed. The only required element is either the 'title', or a 'description'. We settled on requiring a title.
| $title | The title of the item. |
| $elements | Key and value pairs of item elements, and their values. See below for examples. |
| Example | |
The url link of the item.
| Example | |
A description of the item. To include html in your description then wrap it in CDATA tags like so:
<![CDATA[An <b>HTML</b> description.]]>
| Example | |
The author's email address.
| Example | |
A category that the item belongs to.
| Example | |
A url address where comments for the item are located.
| Example | |
A media object attached to the item. All three attributes ('url, 'length', and 'type') are required.
| Example | |
A "globally unique identifier" for the item. It can be a string, url, number . . . anything as long as it remains unique. If you would like to include the 'isPermaLink' attribute, just make it an array.
| Example | |
When the item was published.
| Example | |
The name (title) of the RSS channel that the item came from. It has a required 'url' attribute, so define it like so:
| Example | |
This method puts the whole RSS Feed together, sets the appropriate header, echo's the xml, then exits the script.
| Example | |